﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.Processs;
using ERP.Domain.SalesManagement;
using MediatR;
using Sell.Api.Write.Application.Command.Pro;
using Sell.Services.Pro;

namespace Sell.Api.Write.Application.CommandHandlers.Pro
{
    public class IProUpdateCommandHandlers : IRequestHandler<IProUpdateCommand, ApiResult<int>>
    {
        public IMapper Mapper { get; }
        public IProServices services { get; }
        public IProUpdateCommandHandlers(IMapper _Mapper, IProServices _services)
        {
            Mapper = _Mapper;
            services = _services;
        }
        /// <summary>
        /// 工序管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ApiResult<int>> Handle(IProUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = Mapper.Map<PSrocess>(request);
            return await services.UpdatePSrocess(list);
        }
    }
}
